<template>
  <el-switch
    ref="el"
    :value="value"
    v-bind="$props.props"
    v-on="$listeners"
    @change="handleChange"
  />
</template>

<script>
import Vue from 'vue';
import {Switch} from "element-ui";
Vue.use(Switch);
/**
 * element-ui的[el-switch](https://element.eleme.cn/2.13/#/zh-CN/component/switch)
 * @author maolin
 */
export default {
  name: "ErpFormSwitch",
  components: {
  },
  props: {
    /**
     * 标题
     * @public
     */
    title: {
      type: String,
      default: '',
    },
    /**
     * 字段
     * @public
     */
    field: {
      type: String,
      default: ''
    },
    /**
     * 值
     * @public
     */
    value: {
      default () {
        return '';
      }
    },
    /**
     * 属性
     * @public
     */
    props: {
      type: Object,
      default () {
        return {};
      }
    }
  },
  computed: {
  },
  mounted() {
  },
  methods: {
    /**
     * switch获取焦点
     * @public
     */
    focus () {
      this.$refs.el.focus();
    },
    /**
     * 更新值
     * @param {string|number} e 值
     * @public
     */
    handleChange (e) {
      this.$emit('value-change', e);
    }
  }
};
</script>

<style lang="scss" scoped>
</style>
